#include "memPlayer.h"
#include <MAUI/ListBox.h>
#include <MAUI/Image.h>
#include <madmath.h>
#include <mastdlib.h>
#include <ma.h>
#include <mavsprintf.h>

memPlayer::memPlayer(){
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < 4; j++){
			cards[i][j] = -1;
		}
	}
	setCards();
	doubleCheck();
}

int memPlayer::getCard(int i, int j){

	return cards[i][j];
}

void memPlayer::setCards(){

	int tempCards[8];
	int tempSuit[8];
	int number;
	int randCard = 0;
	int t1 = 0;
	int t2 = 0;
	int arrayNum = 0;
	bool done = false;
	bool tempEmpty = false;

	srand(maTime());
	number = rand() % 7;
	for(int i = 0; i < 8; i++){
		tempCards[i] = number;		// make array tempCards random numbers
		number++;
		if(number > 7)
			number = 0;
	}

	for(int x = 0; x < 8; x++){
		t1 = rand() % 3;			// starts populating in random position
		t2 = rand() % 3;

		if(cards[t1][t2] == -1){	// checks if doesnt already have a value
			cards[t1][t2] = tempCards[x];
			t2++;
		}
		else{
			x--;
		}

		if(t2 > 3){
			t2 = 0;
			t1++;
		}

		if(t1 > 3){
			t1 = 0;
		}
	}

	arrayNum = 0;
	for(int y = 0; y < 4; y++){
		for(int z = 0; z < 4; z++){
			if(cards[y][z] == -1){
				cards[y][z] = tempCards[arrayNum];
				arrayNum++;
			}
		}	// end for z
	}	// end for y

}

void memPlayer::doubleCheck(){
	/*
	cards[3][1] = -1;
	cards[3][2] = -1;
	cards[3][3] = -1;
	*/
}
